#ifdef __cplusplus
extern "C" {
#endif

#ifndef _SERIAL_PROTOCAL_
#define _SERIAL_PROTOCAL_
#include <stdint.h>

#define  MAX_MSG_LEN  128
#define  MSG_HEADER   0xfe

typedef enum{
    UNPACK_SUCCESS = 0x00,
    UNPACK_FAIL=0x01
}unpackInfo;


typedef struct{
	uint64_t timestamp;
    int32_t  lon;
    int32_t  lat;
	int32_t  height;
    float    vel_n;
    float    vel_e;
    float    vel_d;
} gps_info;

typedef struct{
    uint32_t range_anchor1;
    uint32_t range_anchor2;
    uint32_t range_anchor3;
} gps_range_info;


#define GPS_MSG_LEN  sizeof(gps_info)+3  //header + 2 bytes of crc
#define GPS_RANGE_MSG_LEN  sizeof(gps_range_info)+3  //header + 2 bytes of crc


// TODO to determine the size of a float data
void msg_gps_pack(const gps_info*  gpsinfo, uint8_t* msgbuffer);
unpackInfo msg_gps_unpack(gps_info*  gpsinfo, uint8_t* msgbuffer);

void msg_gps_range_pack(const gps_range_info* _gps_range_info, uint8_t* msgbuffer);
unpackInfo msg_gps_range_unpack(gps_range_info* _gps_range_info, uint8_t* msgbuffer);


#endif

#ifdef __cplusplus
}
#endif

